/**
 * Created by yangrourou on 16/11/16.
 */
class requestController extends commonController{
    constructor(){
        super();
        /*
         *初始化成员属性
         */
        requestController.prototype.baseConfig = this.getConfig("config");
        requestController.prototype.apiName = '';
        requestController.prototype.request =  {
            headers:{},
            data:{}
        };
        requestController.prototype.response = '';
    }
    setApiName(apiName){
        this.apiName = apiName;
    }
    setRequest(request){
        console.log(this.getToken());
        this.request.headers.token = this.getToken();
        this.request.headers.appId = this.baseConfig.serviceConfig.appID;
        this.request.headers.appKey = this.baseConfig.serviceConfig.appKey;
        this.request.headers.url = this.baseConfig.serviceConfig.url + this.getApiName();
        this.request.data = request;
    }
    getApiName(){
        return this.apiName;
    }
    setResponse(){
        this.response = this.responseData;
    }
    getResponse(){
        return this.response;
    }
    getRequest(){
        return this.request;
    }
    post(){
        this.doPost(this.getRequest());
        this.setResponse();
    }
    getJsonModel(app,model){
        // $.ajaxSettings.async = false;
        // var jsonData;
        // $.ajax({
        //     type: "post",
        //     async:false,
        //     url: "/zt.php?s=/home/index/getJsonModel",
        //     dataType : 'json',
        //     data: {"app":app,"model":model},
        //     success: function(data){
        //         alert(data);
        //         jsonData = data[0].json;
        //     },
        //     error : function() {
        //         alert('模块加载失败1');
        //     }
        // });
        // console.log(jsonData);
        // console.log(localStorage[app+'_'+model]);
        // return jsonData;
        console.log(localStorage[app+'_'+model]);
        return JSON.parse(localStorage[app+'_'+model]);
    }
}